import request from '@/api/request/axios'

// 知识库常见知识树
export const knowBussinessTree = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeCategory/list',
  method: 'post',
  params: params,
  headers: {
    'Content-Type': 'application/json'
  }
})
//知识随行常见知识树
export const knowledgeTree = (params) => request({
  url: window.CONFIG.idpUrls + '/knowledge/category/getAll',
  method: 'get',
  params: params
})
//知识随行问题列表
export const getknowledgeList = (params) => request({
  url: window.CONFIG.idpUrls + '/knowledge/faq/search',
  method: 'get',
  params: params
})
//知识随行答案列表
export const getknowAnswerList = (params) => request({
  url: window.CONFIG.idpUrls + '/knowledge/faq/findById',
  method: 'get',
  params: params
})
// 知识库常见知识列表
//export const knowledgeList = (params) => request({
//  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/page',
//  method: 'post',
//  params: params
//})

// ai智能搜索
export const aiSearch = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/aiSearch',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})
//ai搜索
export const aiServerPage = (data) => {
  return request({
    url: window.CONFIG.kbp.bladeUserUrl + '/aiServer/page',
    method: 'post',
    data: data
  })
}
// 相关推荐搜索
export const suggestSearch = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/suggest',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

// 获取知识详情
export const getArticleById = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/getArticleById',
  method: 'post',
  params: params
})

export const articleSaveOrEdit = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/saveOrEdit',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

export const genAbstract = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/genAbstract',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

// 删除该条知识
export const delArticle = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/remove',
  method: 'post',
  params: params
})

// 发布评论
export const addComment = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgecomment/addComment',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

// 删除评论
export const delComment = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgecomment/delComment',
  method: 'post',
  params: params
})

// 点赞/取消点赞
export const collectOrNotCollect = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeStar/insertStar',
  method: 'post',
  params: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

// 点赞/取消点赞
export const agreeOrNotAgree = (params) => request({
  url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeagree/agreeOrNotAgree',
  method: 'post',
  data: params,
  headers: {
    'Content-Type': 'application/json'
  }
})

// 文件服务器-文件上传
export const uploadFile = (formData, filetype) => request({
  url: window.CONFIG.fileServer + '/put?filechannel=h5&filetype='+ filetype +'&tenantid=boc',
  method: 'post',
  data: formData,
  contentType: false,
  processData: false,
  dataType: 'text',
  headers: {
    'Content-Type': 'multipart/form-data',
  }
})

// 获取业务类型
export const getKnowledgeType = (params) => {
  return request({
    url: window.CONFIG.kbp.bladeUserUrl + '/businessType/page',
    method: 'post',
    params: params
  })
}

// 提交提问知识
export const submitKnowledge = (params) => {
  return request({
    url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeQuestion/submitQuestion',
    method: 'post',
    params: params
  })
}
// 首页知识搜索
export const knowledgeListHome = (params) => {
  return request({
    url: window.CONFIG.kbp.bladeUserUrl + '/knowledgeArticle/selectIndexKnowledge',
    method: 'post',
    params: params
  })
}
